﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.IO;
using System.Diagnostics;
using System.ComponentModel;
using Newtonsoft.Json;

namespace MetaData
{
    public class MetaDataBag
    {
        [Category("Meta")]
        public Size TableSize { get; set; }
        [Category("Meta")]
        public Size BoardCardSize { get; set; }
        [Category("Meta")]
        public Size HoleCardSize { get; set; }
        [Category("Meta")]
        public Point[] CommonCards { get; set; }
        [Category("Meta")]
        public Point[] LeftCards { get; set; }
        [Category("Meta")]
        public Point[] RightCards { get; set; }
        [Category("Meta")]
        public Point LeftDealerLocation { get; set; }
        [Category("Meta")]
        public Point RightDealerLocation { get; set; }
        [Category("Meta")]
        public Rectangle LeftFoldRect { get; set; }
        [Category("Meta")]
        public Rectangle RightFoldRect { get; set; }
        [Category("Meta")]
        public Rectangle FoldButtonRect { get; set; }
        [Category("Meta")]
        public Rectangle IambackRect { get; set; }
        [Category("Meta")]
        public Rectangle CheckButtonRect { get; set; }
        [Category("Meta")]
        public Rectangle CallButtonRect { get; set; }
        [Category("Meta")]
        public Rectangle BetButtonRect { get; set; }
        [Category("Meta")]
        public Rectangle RaiseButtonRect { get; set; }
        [Category("Meta")]
        public Point PotFontPixel { get; set; }
        [Category("Meta")]
        public int PotFontColor { get; set; }
        [Category("Meta")]
        public Rectangle PotRect { get; set; }
        [Category("Data")]
        public Dictionary<long, string> PotNumberHashes { get; set; }
        [Category("Data")]
        public Dictionary<int, string> BoardCardHashes { get; set; }
        [Category("Data")]
        public Dictionary<int, string> HoleCardHashes { get; set; }
        [Category("Data")]
        public int LeftDealerHash { get; set; }
        [Category("Data")]
        public int RightDealerHash { get; set; }
        [Category("Data")]
        public int FoldButtonHash { get; set; }
        [Category("Data")]
        public int LeftFoldHash { get; set; }
        [Category("Data")]
        public int RightFoldHash { get; set; }
        [Category("Data")]
        public int CheckButtonHash { get; set; }
        [Category("Data")]
        public int CallButtonHash { get; set; }
        [Category("Data")]
        public int BetButtonHash { get; set; }
        [Category("Data")]
        public int RaiseButtonHash { get; set; }

        public MetaDataBag()
        {
            CommonCards = new Point[5];
            for (int i = 0; i < 5; i++)
            {
                CommonCards[i] = new Point(0, 0);
            }
            LeftCards = new Point[2];
            for (int i = 0; i < 2; i++)
            {
                LeftCards[i] = new Point(0, 0);
            }
        }
        public static MetaDataBag Load()
        {
            MetaDataBag bag = new MetaDataBag();
            if (File.Exists("MetaData.txt"))
            {
                string json = System.IO.File.ReadAllText(@"MetaData.txt");
                bag = JsonConvert.DeserializeObject<MetaDataBag>(json);
            }
            return bag;
        }
        public void Save()
        {
            string json = JsonConvert.SerializeObject(this);
            File.WriteAllText(@"MetaData.txt", json);
        }
    }
}
